/*
 * PnlDibujo.java
 *
 * Created on 14 de agosto de 2008, 02:59 PM
 */
package Vista.panel;

import Vista.Calibrar.Calibrar;
import Vista.configuracion.Settings;
import java.awt.Color;
import java.awt.Graphics;

/**
 *
 * @author Jhon Jairo
 */
public class PnlDibujo extends javax.swing.JPanel {

    private int x;
    private int y;
    int Count = 0;
    public static boolean screenS = false;
    
    /**
     * Creates new form PnlDibujo
     */
    public PnlDibujo() {
        initComponents();
        ScreenShoot.setVisible(false);
        sett.setVisible(false);
        x = -1;
        y = -1;
        
        
    }

    @Override
    public void paint(Graphics g) {
        if (x >= 0 && y >= 0) {
            if (Settings.checkBrush.isSelected()) {
                g.setColor(ColorChooser.color);
                g.fillOval(x, y, Settings.thickness, Settings.thickness);
                g.fillRect(x, y, Settings.thickness, Settings.thickness);
            } else if (Settings.checkEraser.isSelected()) {
                g.setColor(Color.WHITE);
                g.fillOval(x, y, Settings.thickness, Settings.thickness);
            }
        }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        sett = new javax.swing.JButton();
        ScreenShoot = new javax.swing.JButton();

        setBackground(new java.awt.Color(255, 255, 255));
        addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                formMouseClicked(evt);
            }
            public void mousePressed(java.awt.event.MouseEvent evt) {
                formMousePressed(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                formMouseReleased(evt);
            }
        });

        sett.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Vista/Images/config2.png"))); // NOI18N
        sett.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                settActionPerformed(evt);
            }
        });

        ScreenShoot.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Vista/Images/captura.png"))); // NOI18N
        ScreenShoot.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ScreenShootActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(sett, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 284, Short.MAX_VALUE)
                .addComponent(ScreenShoot, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(189, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(ScreenShoot)
                    .addComponent(sett, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(52, 52, 52))
        );
    }// </editor-fold>//GEN-END:initComponents

private void formMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMouseClicked
//    Calibrar.set.setVisible(false);
//    x = evt.getX();
//    y = evt.getY();
//    paint(this.getGraphics());
}//GEN-LAST:event_formMouseClicked

private void settActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_settActionPerformed
    Calibrar.set.setVisible(true);

}//GEN-LAST:event_settActionPerformed

private void ScreenShootActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ScreenShootActionPerformed
    screenS = true;
    Settings.frm.repaint(1000);
    Settings.nm.setVisible(true);


}//GEN-LAST:event_ScreenShootActionPerformed

    private void formMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMousePressed
        Calibrar.set.setVisible(false);
        x = evt.getX();
        y = evt.getY();
        paint(this.getGraphics());
    }//GEN-LAST:event_formMousePressed

    private void formMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMouseReleased
//         Calibrar.set.setVisible(false);
//    x = evt.getX();
//    y = evt.getY();
//    paint(this.getGraphics());
    }//GEN-LAST:event_formMouseReleased

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton ScreenShoot;
    private javax.swing.JButton sett;
    // End of variables declaration//GEN-END:variables
}
